home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 13
/
AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso
/
rexx
/
sofar.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-10-15
|
3KB
|
154 lines
/*
$VER: SoFar (15 Oct 1994)
*/
ARG iNameCode
options results
/* Initialize */
DataPath = "S:TimeKeep/"
if iNameCode = "" then do
Say ""
Say "ERROR: No Client Code"
Say ""
exit
end
/* Read Time Data */
if ~ open('Time', DataPath||iNameCode||".time", 'R') then do
Say ""
Say "ERROR: .time NOT FOUND"
Say ""
exit
end
t = readln('Time')
parse var t '"'Client.NameCode'","'Client.Name'"'
/* Collate */
Projects = "|"; nProjects = 0 ; Expenses = 0; Work = 0
do while ~eof('Time')
t = readln('Time')
parse var t '"'tType'","'tProject'",'tInfo
if tInfo == "" then leave
if index(Projects, "|"tProject"|") = 0 then do
/* Project not found */
Projects = Projects||tProject"|"
nProjects = nProjects + 1
Projects.nProjects.Name = tProject
if tType = "T" then do
Projects.nProjects.count = 1
Expenses.nProjects.count = 0
end
else do
Projects.nProjects.count = 0
Expenses.nProjects.count = 1
end
cProject = nProjects; n = 1
end
else do
/* Project exists */
do lp = 1 to nProjects
if Projects.lp.Name = tProject then leave
end
cProject = lp
if tType = "T" then do
Projects.lp.count = Projects.lp.count + 1
n = Projects.lp.count
end
else do
Expenses.lp.count = Expenses.lp.count + 1
n = Expenses.lp.count
end
end
if tType = "T" then do
Projects.cProject.n.Info = tInfo
Work = 1
end
else do
Expenses.cProject.n.Info = tInfo
Expenses = 1
end
end
call close('Time')
if nProjects = 0 then do
Say ""
Say "ERROR: NO Logged Time or Expenses"
Say ""
exit
end
/* Create Invoice */
Say ""
Say Client.Name
/* Expenses */
TotalExpenses = 0
if Expenses then do
Say ""
Say "== EXPENSES ==========================="
do lp = 1 to nProjects
if Expenses.lp.count = 0 then iterate
Say Projects.lp.Name
do lp2 = 1 to Expenses.lp.count
parse var Expenses.lp.lp2.Info '"'tInfo'","'tAmount'"'
Say " "tInfo" "tAmount
TotalExpenses = TotalExpenses + tAmount
end
end
Say ""
Say " TOTAL EXPENSES $ "TotalExpenses
end
/* Work Hours */
Total = 0
if Work then do
Say ""
Say "== WORK HOURS ========================="
do lp = 1 to nProjects
if Projects.lp.count = 0 then iterate
Say Projects.lp.Name
HSubTotal = 0
do lp2 = 1 to Projects.lp.count
parse var Projects.lp.lp2.Info '"'tDate'","'tT1'","'tT2'","'tH'","'tRate'"'
HSubTotal = HSubTotal + tH
end
SubTotal = trunc(HSubTotal * tRate + .5e-2, 2)
Say " "HSubTotal" @ $"tRate" / hour: "SubTotal
Total = Total + SubTotal
end
Say ""
Say " TOTAL WORK $ "Total
end
Say ""
Say "== TOTAL =============================="
Total = Total + TotalExpenses
Say ""
Say " TOTAL $ "Total
Say ""
exit